<template>
  <ActivityPhonePreview :width="330">
    <div class="bg_phone">
      <div class="header-title">{{ formData.title}}</div>
      <div class="common-layout">
        <el-container>
          <el-main>
            <div class="title">{{ formData.title}}</div>
            <div class="choujiangjihui_num">您今天还有x次抽奖机会</div>
            <div v-if="formData.invite_desc_switch != 2">
              <p class="choujiangjihui_desc1">每分享给x位好友可增加x次抽奖机会</p>
              <p class="choujiangjihui_desc2">最多获得x次抽奖机会，每日最多可以抽奖x次</p>
            </div>
            <div class="top">
              <div class="prize_img_box">
                <div :class="['prize', `rectangular${formData.reward_attr.length >= 2 ? formData.reward_attr.length : 2}`]">
                  <div class="begin"></div>
                    <div class="reward_attr">
                    <div :class="`reward_attr_item${formData.reward_attr.length}`" v-for="(item,index) in formData.reward_attr">
                    <el-image   :src="item.reward_image" alt="" style="width:32px;height:32px">
                    <template #error>
                        <span></span>
                    </template>
                    </el-image>
                    <div>{{item.reward_title}}</div>
                    </div>
                    </div>
                </div>
              </div>
            </div>
          </el-main>
        </el-container>
      </div>
    </div>
  </ActivityPhonePreview>
</template>
<script setup lang="ts">
import { ref, reactive, onUnmounted, watch } from 'vue'
import bus from '@/utils/bus';
import ActivityPhonePreview from '../index.vue'

const props = defineProps({
  rewardInfo: {
    type: Object,
    default: () => ([])
  },
  inviteDescSwitch: {
    type: [Number,String],
    default: 1
  }
})

const formData = ref({
    // exchange_type: 1, //	兑奖时间 1-活动期限 2-活动结束1
    title:'',//	活动标题
    reward_attr: [
      {
        reward_type: 3, //	奖品类型 1-实物 2-普通红包
        red_envelope_type: 1, //红包类型 1-普通红包 2-拼手气红包
        reward_title: '谢谢参与', //	奖品标题 （实物）
        red_envelope_money: 0, //
        red_envelope_num: 1, //
        red_envelope_total: 0, //
        red_envelope_range: 0, // 单个金额右
        reward_image: '', //	奖品图片（实物）奖品图片url
        reward_stock: 0, //	奖品库存（实物）
        reward_desc: 0, //	奖品描述（描述）
        reward_probability: 100 //	奖品概率
      }
    ], //	奖品设置1
    invite_desc_switch: 1 // 分享描述是否展示 1-展示 2-隐藏
})

watch(()=>props.rewardInfo, () => {
  let arr = []
  props.rewardInfo.forEach(item => {
    arr.push({
      reward_type: item.reward_type, //	奖品类型 1-实物 2-普通红包
      reward_image: item.reward_image, //	奖品图片（实物）奖品图片url
    })
  });
  formData.value.reward_attr = arr
},{immediate:true,deep:true})

watch(()=>props.inviteDescSwitch, () => {
  formData.value.invite_desc_switch = props.inviteDescSwitch
})

bus.on('stepOne', (data) => {
  console.log(data);
  
  formData.value.title = data
})

onUnmounted(() => {
  bus.off('stepOne')
})

</script>
<style lang="scss" scoped>
.bg_phone {
  width: 100%;
  min-height: 495px;
  box-sizing: border-box;
  overflow: hidden;
  justify-content: center;
  background-color: #f1f7f9;
  .header-title {
    background: #ffffff;
    border-radius: 1px;
    border-bottom: 1px solid #f5f5f5;
    position: relative;
    text-align: center;
    font-size: 16px;
    font-family: STHeitiSC-Medium, STHeitiSC;
    font-weight: 500;
    color: #000000;
    height: 42px;
    line-height: 44px;
    text-align: center;
    position: absolute;
    top: 0;
    right: 0;
    text-align: center;
    width: 100%;
    z-index: 1;
  }
  .common-layout {
    width: 100%;
    border-radius: 10%;
    margin-top: 42px;
    // background: url('@/assets/smartMarketing/themaskset.png') no-repeat;
    .el-container {
      width: 100%;
      height: 603px;
      font-size: 12px;
      color: #000;
      border-radius: 0 0 20px 20px;
      background-color: #fe6622;

      .title {
        position: absolute;
        top: 48px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 22px;
        text-align: center;
        color: #fffce3;
        width: 300px;
        white-space:nowrap;
        overflow:hidden;
        text-overflow:ellipsis;
      }
      .el-main {
        width: 100%;
        height: 100%;
        padding: 0;
        overflow: hidden;
        position: relative;
        .choujiangjihui_num{
          position: absolute;
          top: 220px;
          left: 50%;
          transform: translateX(-50%);
          word-break: keep-all;
          padding: 4px 15px;
          color: #fff;
          background: #FD8729;
          border-radius: 15px 15px 15px 15px;
          opacity: 1;
          border: 1px solid #FFCA99;
        }
        .choujiangjihui_desc1{
          position: absolute;
          top: 557px;
          left: 50%;
          word-break: keep-all;
          transform: translateX(-50%);
          color: #fff;

        }
        .choujiangjihui_desc2{
          width: 100%;
          text-align: center;
          position: absolute;
          top: 577px;
            // left: 50%;
            word-break: keep-all;
            // transform: translateX(-50%);
            color: #fff;

        }

        .top {
          display: flex;
          justify-content: center;
          width: 100%;
          height: 605px;
          // padding-top: 340px;
          // margin-top: -5px;
          margin-bottom: 15px;
          background: url('@/assets/smartMarketing/themaskset.png') no-repeat;
          background-size: 100% 100%;

          .prize_img_box {
            margin-top: 260px;
            height: 230px;
            padding: 24px;
            background: url('@/assets/smartMarketing/outerring.png') no-repeat;
            background-size: 100% 100%;
            background-position: -7px 0px;

            .one {
              width: 20px;

              img {
                width: 40px;
              }
            }
            .ones {
              width: 40px;
              height: 40px;
              margin: 10px 0 10px 5px;
            }
            .rectangular2 {
              background: url('@/assets/smartMarketing/rectangular2.png') no-repeat;
              background-size: 100% 100%;
            }

            .rectangular3 {
              background: url('@/assets/smartMarketing/rectangular3.png') no-repeat;
              background-size: 100% 100%;
            }

            .rectangular4 {
              background: url('@/assets/smartMarketing/rectangular4.png') no-repeat;
              background-size: 100% 100%;
            }

            .rectangular5 {
              background: url('@/assets/smartMarketing/rectangular5.png') no-repeat;
              background-size: 100% 100%;
            }

            .rectangular6 {
              background: url('@/assets/smartMarketing/rectangular6.png') no-repeat;
              background-size: 100% 100%;
            }

            .rectangular7 {
              background: url('@/assets/smartMarketing/rectangular7.png') no-repeat;
              background-size: 100% 100%;
            }

            .rectangular8 {
              background: url('@/assets/smartMarketing/rectangular8.png') no-repeat;
              background-size: 100% 100%;
            }

            .prize {
              display: flex;
              justify-content: center;
              font-size: 10px;
              align-items: center;
              position: relative;
              top: -10px;
              width: 230px;
              height: 230px;
              // background: url('@/assets/smartMarketing/rectangular4.png') no-repeat;
              background-size: 100% 100%;
              border-radius: 50%;

              .begin {
                display: flex;
                justify-content: center;
                align-items: center;
                width: 26%;
                height: 32%;
                border-radius: 50%;
                color: #fff;
                background: url('@/assets/smartMarketing/luckydraw.png') no-repeat;
                background-size: cover;
              }
              .reward_attr{
                width: 100%;
                height: 100%;
                border-radius: 50%;
                position: absolute;
                font-size: 12px;
                
                .reward_attr_item2{
                  text-align: center;
                  position: absolute;
                  &:nth-child(1){
                    transform:  translate(-25%, 215%) rotate(270deg);
                    div{
                      width: 200px;
                      height: 12px;
                    }
                  }
                  &:nth-child(2){
                    position: absolute;
                    transform:  translate(41%, 215%) rotate(90deg);
                    div{
                      width: 200px;
                      height: 12px;
                  
                    }
                  }
                }
                .reward_attr_item3{
                  text-align: center;
                  position: absolute;
                  &:nth-child(1){
                    transform: translate(-36%, 128%) rotate(306deg);
                    div{
                      width: 400px;
                      height: 12px;
                    }
                  }
                  &:nth-child(2){
                    transform: translate(-6%, 128%) rotate(40deg);
                    div{
                      width: 400px;
                      height: 12px;
                    }
                  }
                  &:nth-child(3){
                    transform: translate(-21%, 348%) rotate(180deg);
                    div{
                      width: 400px;
                      height: 12px;
                    }
                  }
                }
                .reward_attr_item4{
                  text-align: center;
                  position: absolute;
                  &:nth-child(1){
                    transform: translate(34%, 90%) rotate(312deg);
                    div{
                      width: 80px;
                      height: 12px;
                    }
                  }
                  &:nth-child(2){
                    transform: translate(150%, 90%) rotate(45deg);
                    div{
                      width: 80px;
                      height: 12px;
                    }
                  }
                  &:nth-child(3){
                    transform: translate(152%, 304%) rotate(135deg);
                    div{
                      width: 80px;
                      height: 12px;
                    }
                  }
                  &:nth-child(4){
                    transform: translate(33%, 300%) rotate(225deg);
                    div{
                      width: 80px;
                      height: 12px;
                    }
                  }
                  
                }
                .reward_attr_item5{
                  text-align: center;
                  position: absolute;
                  &:nth-child(1){
                    transform: translate(98%, 70%) rotate(315deg);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(2){
                    transform: translate(268%, 70%) rotate(45deg);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(3){
                    transform: translate(320%, 240%) rotate(120deg);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(4){
                    transform: translate(180%, 336%) rotate(180deg);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(5){
                    transform: translate(40%, 240%) rotate(240deg);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                
                  
                }
                .reward_attr_item6{
                  text-align: center;
                  position: absolute;
                  &:nth-child(1){
                    transform:  translate(248%, 59%) rotate(45deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(2){
                    transform: translate(315%, 190%) rotate(90deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(3){
                    transform: translate(255%, 336%) rotate(140deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(4){
                    transform: translate(100%, 329%) rotate(213deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(5){
                    transform: translate(30%, 196%) rotate(270deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(6){
                    transform: translate(99%, 60%) rotate(316deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                }
                .reward_attr_item7{
                  text-align: center;
                  position: absolute;
                  &:nth-child(1){
                    transform:   translate(236%, 62%) rotate(37deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(2){
                    transform: translate(323%, 162%) rotate(70deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(3){
                    transform: translate(302%, 304%) rotate(123deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(4){
                    transform: translate(180%, 356%) rotate(180deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(5){
                    transform: translate(66%, 296%) rotate(228deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(6){
                    transform: translate(26%, 155%) rotate(288deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(7){
                    transform: translate(115%, 47%) rotate(336deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                }
                .reward_attr_item8{
                  text-align: center;
                  position: absolute;
                  &:nth-child(1){
                    transform: translate(243%, 42%) rotate(25deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  
                  &:nth-child(2){
                    transform: translate(325%, 130%) rotate(70deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  
                  
                  &:nth-child(3){
                    transform: translate(323%, 260%) rotate(113deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  
                  &:nth-child(4){
                    transform: translate(237%, 350%) rotate(154deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(5){
                    transform: translate(126%, 341%) rotate(204deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(6){
                    transform: translate(42%, 256%) rotate(245deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(7){
                    transform: translate(33%, 130%) rotate(290deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                  &:nth-child(8){
                    transform: translate(126%, 51%) rotate(329deg) scale(0.8);
                    div{
                      width: 50px;
                      height: 12px;
                    }
                  }
                }  
              }
            }
          }

        .content {
          display: flex;
          flex-direction: column;
          align-items: center;

          .text {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 95%;
            height: 40px;
            border-radius: 2%;
            margin-bottom: 10px;
            background-color: #ffea58;
          }

          .text_p {
            flex-direction: column;

            p {
              margin-bottom: 5px;
            }
          }
        }
      }

      .el-footer {
        height: 40px;
        padding: 0 8px;
        border-radius: 2%;
      }
    }
  }
}
}
</style>
